package nc.bs.cad.func;

import java.util.HashMap;
import java.util.Stack;

import nc.bs.logging.Logger;
import nc.vo.capub.formular.FormulaParseVO;
import nc.vo.pub.lang.UFDouble;

import org.nfunk.jep.ParseException;
import org.nfunk.jep.function.PostfixMathCommand;

@SuppressWarnings("unchecked")
public class GetHisLossRateFunc extends PostfixMathCommand {

	public FormulaParseVO para = null;

	public GetHisLossRateFunc() {
		numberOfParameters = 0;
	}

	public GetHisLossRateFunc(FormulaParseVO para) {
		this.para = para;
		numberOfParameters = 0;
	}

	public void run(Stack st) throws ParseException {
		checkStack(st);
		Object val = null;
		HashMap hmCodeToVal = para.getHmCodeToVal();
		try {
			val = hmCodeToVal.get("avelossrate");
			if (val == null) {
				val = new UFDouble(0.00);
			} else {
				val = new UFDouble(val.toString());
			}
		} catch (Exception e) {
			Logger.error(e.getMessage());
			throw new ParseException(e.getMessage());
		}
		st.push(val);
	}
}